package com.timyu.greendaoforandroidstudio;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;
import greendao.DaoMaster;
import greendao.DaoSession;

/**
 * Created by timyu on 3/27/15.
 */
public class MyApplication extends Application
{

    private DaoSession daoSession;

    @Override
    public void onCreate()
    {
        super.onCreate();
        setupDatabase();
    }

    private void setupDatabase()
    {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "example-db", null);
        SQLiteDatabase db = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();

    }

    public DaoSession getDaoSession()
    {
        return daoSession;
    }
}
